package tests;

import java.io.IOException;

import lib.rpc.IClientRPCFunctionality;
import lib.rpc.RPCInvokePacket;
import lib.rpc.RPCResultPacket;

/**
 * Mock implementation of IRPCFunctionality for unittests
 * 
 * @implements {@link IClientRPCFunctionality}
 * @author abhip
 * 
 */
public class TestRPCFunctionality implements IClientRPCFunctionality {
    private IClientRPCFunctionality testRPCFunctionality;

    public TestRPCFunctionality() {
        this(null);
    }

    public TestRPCFunctionality(IClientRPCFunctionality testRPFunctionality) {
        this.testRPCFunctionality = testRPFunctionality;
    }

    @Override
    public RPCResultPacket Invoke(RPCInvokePacket rpcInvokePacket)
            throws IOException, ClassNotFoundException {
        if (testRPCFunctionality != null) {
            return testRPCFunctionality.Invoke(rpcInvokePacket);
        }

        return null;
    }
}
